<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>主题风格</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="{__STATIC__}/layuiAdmin/layui/css/layui.css" rel="stylesheet">
	<link href="{__STATIC__}/layuiAdmin/adminui/dist/css/admin.css" rel="stylesheet">
	<link href="{__STATIC__}/layuiAdmin/style/style.css" rel="stylesheet">
	<style>
		.layui-form-item img {
			width: 480px;
			height: auto;
		}
	</style>
</head>
<body>
<div class="layui-fluid">
	<form class="layui-form" style="padding-bottom: 45px;">
		<div class="layui-card">
			<div class="layui-card-body">
				<div class="layui-tab layui-tab-brief">
					<ul class="layui-tab-title">
						<li class="layui-this">主题风格</li>
					</ul>
					<div class="layui-tab-content">
						<div class="layui-tab-item layui-show">
							<div class="layui-form-item">
								<label class="layui-form-label">选择风格：</label>
								<div class="layui-input-inline">
									<input type="radio" name="m_theme" value="default" lay-filter="type" title="默认风格" {eq name="$setting.theme" value="default"}checked{/eq}>
									<input type="radio" name="m_theme" value="blue" lay-filter="type" title="商务蓝" {eq name="$setting.theme" value="blue"}checked{/eq}>
									<input type="radio" name="m_theme" value="green" lay-filter="type" title="农业绿" {eq name="$setting.theme" value="green"}checked{/eq}>
								</div>
							</div>
							<div class="layui-form-item" id="span_pic1" {neq name="$setting.theme" value="default"}style="display: none"{/neq}>
								<div class="layui-input-block">
									<img src="/upload/pic/public/default.png">
								</div>
							</div>
							<div class="layui-form-item" id="span_pic2" {neq name="$setting.theme" value="blue"}style="display: none"{/neq}>
								<div class="layui-input-block">
									<img src="/upload/pic/public/blue.png">
								</div>
							</div>
							<div class="layui-form-item" id="span_pic3" {neq name="$setting.theme" value="green"}style="display: none"{/neq}>
								<div class="layui-input-block">
									<img src="/upload/pic/public/green.png">
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="m_footer">
			<button class="layui-btn layui-btn-normal" lay-submit lay-filter="LAY-submit">提交</button>
			<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
    </form>
</div>
</body>
</html>
<script src="{__STATIC__}/layuiAdmin/layui/layui.js"></script>
<script>
	layui.config({
		base: '{__STATIC__}/layuiAdmin/' // 静态资源所在路径
	}).use(['index','form'], function(){
		let $ = layui.$;
		let layer = layui.layer;
		let form = layui.form;

		/* 监听radio */
		form.on('radio(type)',function (data) {
			if(data.value=='default'){
				$("#span_pic1").show();
				$("#span_pic2").hide();
				$("#span_pic3").hide();
			}
			if(data.value=='blue'){
				$("#span_pic1").hide();
				$("#span_pic2").show();
				$("#span_pic3").hide();
			}
			if(data.value=='green'){
				$("#span_pic1").hide();
				$("#span_pic2").hide();
				$("#span_pic3").show();
			}
		});

		/* 监听提交 */
		form.on('submit(LAY-submit)', function(data){
			let field = data.field; //获取提交的字段
			$.ajax({
				type:"post",
				url:"saveTheme.html",
				data: {
					theme:field.m_theme
				},
				dataType:"json",
				beforeSend: function () {
					layer.load(1);
				},
				success:function(res){
					layer.closeAll(); //关闭弹层
					if(res.code == 0){
						layer.msg('修改成功', {
							time: 2000
						}, function(){
							location.reload();
						});
					}
					else {
						layer.msg(res.msg);
					}
				}
			});
			return false;
		});
	});
</script>